#!/usr/bin/python
# -*- coding: utf-8 -*-
# CreateDate: 2018-1-10

from manager.models import db
from flask import Flask
from flask_apscheduler import APScheduler  # 引入APScheduler
from manager.apiManager import api_bp

# from gate.gateWebsocket import GateWebsocket


# def print_hello(a, b):  # 一个函数，用来做定时任务的任务。
#     print('hello ********* ' + str(a) + ' ,' + str(b))

def kline_monitoring():
    # for gate_thread in GateKlineWebsocket.all_Thread:
    #     if not gate_thread.isRunning:
    #         # app_context = app.app_context()
    #         # app_context.push()
    #         gate_thread.start()
    #         # app_context.pop()
    #         # gate_thread.run()
    #         print('hello ------------ ')

    print('hello ------------ ')
    # print('hello ++++++++++ %s' % GateWebsocket.all_Thread)



def create_app(config_filename):
    app = Flask(__name__)
    app.config.from_object(config_filename)

    # scheduler = APScheduler()  # 实例化APScheduler
    # scheduler.init_app(app)  # 把任务列表放进flask
    # scheduler.start()  # 启动任务列表


    db.init_app(app)
    app_context = app.app_context()
    app_context.push()
    db.create_all()
    app_context.pop()



    app.register_blueprint(api_bp, url_prefix='/api')

    return app

app = create_app("config")

if __name__ == "__main__":

    app.run(host='127.0.0.1', port=5000, debug=True,threaded=True)



